/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package utility;

import java.io.Serializable;
import java.util.ResourceBundle;
import java.util.UUID;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

/**
 *
 * @author nivri
 */
public class apputils implements Serializable{
        
    public static String getMessegesBundles(String key){
    FacesContext context = FacesContext.getCurrentInstance();
    ResourceBundle bundle = context.getApplication().getResourceBundle(context, "msg");
    String message = bundle.getString(key);

    return message;

    }
    
    
    
    
    
    
    
    
    public static void addmessageswarn(String messages){
    
    FacesContext context = FacesContext.getCurrentInstance();  
    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,apputils.getMessegesBundles(messages),"")); 
    }
    
    public static void addmessagesok(String messages){
    FacesContext context = FacesContext.getCurrentInstance();  
    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,apputils.getMessegesBundles(messages),"")); 
    }
        
    public static void addmessageserror(String messages){
    FacesContext context = FacesContext.getCurrentInstance();  
    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,apputils.getMessegesBundles(messages),"")); 
    }
    
    
    public static void addsimplemessages(String message){
    FacesContext context = FacesContext.getCurrentInstance();  
    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,message,"")); 
    
    
    }
    
    public static void addsimpremessageswarn(String message){
    FacesContext context = FacesContext.getCurrentInstance();  
    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_WARN,message,"")); 
    
    
    }
    
       
    
    public static void addsimplemessageserror(String message){
    FacesContext context = FacesContext.getCurrentInstance();  
    context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,message,"")); 
    
    
    }
    
    public static  String getUuid() {

        return UUID.randomUUID().toString();

    }

    
}
